<?php


use PHPUnit\Framework\TestCase;
use Xp\Feedback\ConfigLoader;
use Xp\Feedback\Feedback;

final class FeedbackComponentTest extends TestCase
{
    private Feedback $feedbackComponent;

    protected function setUp(): void
    {
        parent::setUp();
        $this->feedbackComponent = Feedback::getInstance(new ConfigLoader(null));
    }

    public function testInitializeTable(): void
    {
        $this->feedbackComponent->initializeTable();
        $this->assertTrue(true); // 简单示例，实际应验证表是否已创建
    }

    public function testAddAndGetFeedback(): void
    {
        $newFeedbackId = $this->feedbackComponent->addFeedback(123,"John Doe",'john.doe@example.com',null);

        $feedbacks = $this->feedbackComponent->getAllFeedbacks();
        $this->assertGreaterThan(0, count($feedbacks));
        $this->assertEquals('John Doe', $feedbacks[0]['name']);
    }
}